<?php 
  error_reporting(0);
  session_start();
  $logout = isset($_GET['logout']) ? md5($_GET['logout']) :'';
  if($logout)
  {
	  $_SESSION['isLogin'] = '';
  }else{
	if(isset($_SESSION['isLogin']) && $_SESSION['isLogin'])
	  {
		header("location:/main.php");
	  }
  }
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>汽车运行监控系统</title>
    <link href="/css/bootstrap.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
  </head>
<body>
<div id="login-page">
      <div class="container">
          <form class="form-login" action="index.html">
            <h2 class="form-login-heading">汽车运行监控系统</h2>
            <div class="login-wrap">
                <input type="text" id="username" class="form-control" placeholder="账号">
                <br>
                <input type="password" id="password" class="form-control" placeholder="密码">
                <label class="checkbox">
                    <span class="pull-right">
                        <a data-toggle="modal"> </a>
                    </span>
                </label>
                <span id="J_login" onclick="J_login()" class="btn btn-theme btn-block" type="submit">登&nbsp;&nbsp;录</span>
                <hr>
            </div>
          </form>     
      </div>
    </div>
    </body>
</html>
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/jquery.backstretch.min.js"></script>
<script>
        $.backstretch("/image/login-bg.jpg", {speed: 500});
</script>
<script>
function J_login(){

        var username = $("#username").val();
        var password = $("#password").val();
        if(username == '')
        {
            alert("账号不能为空");
            $("#username").focus();
            return false;
        }
        if(password == '' || password == "●●●●●●")
        {
             alert("密码不能为空");
             $("#password").focus();
             return false;
        }
         $.post("/login.php",{"username":username,"password":password},function(data){
            if(data.code == 200)
            {
                window.location.href="/main.php";
            }else{
                alert(data.message);
            }
        },"json");
   };
</script>